<!DOCTYPE html>
<html>
<head>
<title>Weiran ECMAScript Applications Framework</title>
<link rel=stylesheet type=text/css href=./style.css>
</head>

<body>

<div class=leftbar>
    <h1>Weiran</h1>
    <p>ECMAScript<br />Applications Framework</p>
    <p>Version: 1.2</p>
    <ul>
	<li><a href=Weiran.html>Weiran</a></li>
	<li><a href=Weiran.Array.html>Weiran.Array</a></li>
	<li><a href=Weiran.Buffer.html>Weiran.Buffer</a></li>
	<li><a href=Weiran.Class.html>Weiran.Class</a></li>
	<li><a href=Weiran.Date.html>Weiran.Date</a></li>
	<li><a href=Weiran.DB.html>Weiran.DB</a></li>
	<li><a href=Weiran.Event.html>Weiran.Event</a></li>
	<li><a href=Weiran.Events.html>Weiran.Events</a></li>
	<li><a href=Weiran.Function.html>Weiran.Function</a></li>
	<li><a href=Weiran.JSON.html>Weiran.JSON</a></li>
	<li><a href=Weiran.Lang.html>Weiran.Lang</a></li>
	<li><a href=Weiran.Number.html>Weiran.Number</a></li>
	<li><a href=Weiran.String.html>Weiran.String</a></li>
	<li>GRUB Mechanism<ul>
	    <li><a href=#Weiran.require>Weiran.require</a></li>
	    <li><a href=#Weiran.requireCSS>Weiran.requireCSS</a></li>
	    <li><a href=#Weiran.removeCSS>Weiran.removeCSS</a></li>
	    <li><a href=#Weiran.replaceCSS>Weiran.replaceCSS</a></li>
	</ul></li>
    </ul>
    <p>
        Copyright &copy; All<span>i</span>dylls<br />
        2011 - 2012
    </p>
</div>

<div class=content>

<div class=reftitle>GRUB Mechanism</div>
<p><code>Weiran</code> has a mechanism to start applicatons automatically and load required resources sequentially.</p>
<p>There are two steps for doing this:</p>
<p>1, Add a <code>data-grub</code> attribute to the script tag which <code>src</code> is the main Weiran script file, eg:</p>
<p><code><pre>
    &lt;script src=weiran.js data-grub=grub.js&gt;&lt;/script&gt;</pre></code></p>
<p>2, Load required resources and run the applicaton in the scirpt file referenced by <code>data-grub</code>, eg:</p>
<p><code><pre>
    Weiran.require(['a.js', 'b.js', 'c.js'], function() {
        Weiran.require(['x.js', 'y.js'], function() {
           var app = new MyApp();
           app.run();
        });
    });</pre></code></p>
<p>That will do!</p>

<a name=Weiran.require></a>
<h3><code>Weiran.require(urls, callback, doc)</code></h3>
<p><b>Static method</b></p>
<p>
    <b>Parameters: </b><br />
    <span class=parameters>urls</span> - <code>string | array</code>, script file URL(s)<br />
    <span class=parameters>callback</span> - <code>function</code>, optional<br />
    <span class=parameters>doc</span> - <code>document</code>, optional context, defaults to current <code>document</code>
</p>
<p><b>Returns: </b><code>undefined</code></p>
<p>Loads scirpt file(s) into doc context. The callback will be executed after all files loaded.
		    If a doc is not set, then load all files into current <code>document</code>.</p>

<a name=Weiran.requireCSS></a>
<h3><code>Weiran.requireCSS(url, callback, doc)</code></h3>
<p><b>Static method</b></p>
<p>
    <b>Parameters: </b><br />
    <span class=parameters>url</span> - <code>string</code>, stylesheet file URL<br />
    <span class=parameters>callback</span> - <code>function</code>, optional<br />
    <span class=parameters>doc</span> - <code>document</code>, optional context, defaults to current <code>document</code>
</p>
<p><b>Returns: </b><code>undefined</code></p>
<p>Loads css file into doc context. The callback will be executed after the file loaded.
		    If a doc is not set, then load file into current <code>document</code>.</p>

<a name=Weiran.removeCSS></a>
<h3><code>Weiran.removeCSS(url, callback, doc)</code></h3>
<p><b>Static method</b></p>
<p>
    <b>Parameters: </b><br />
    <span class=parameters>url</span> - <code>string</code>, stylesheet file URL<br />
    <span class=parameters>callback</span> - <code>function</code>, optional<br />
    <span class=parameters>doc</span> - <code>document</code>, optional context, defaults to current <code>document</code>
</p>
<p><b>Returns: </b><code>undefined</code></p>
<p>Removes css file from doc context. The callback will be executed after the file removed.
		    If a doc is not set, then remove file from current <code>document</code>.</p>

<a name=Weiran.replaceCSS></a>
<h3><code>Weiran.replaceCSS(oldurl, newurl, callback, doc)</code></h3>
<p><b>Static method</b></p>
<p>
    <b>Parameters: </b><br />
    <span class=parameters>oldurl</span> - <code>string</code>, stylesheet file which will be removed<br />
    <span class=parameters>newurl</span> - <code>string</code>, stylesheet file which will be loaded<br />
    <span class=parameters>callback</span> - <code>function</code>, optional<br />
    <span class=parameters>doc</span> - <code>document</code>, optional context, defaults to current <code>document</code>
</p>
<p><b>Returns: </b><code>undefined</code></p>
<p>Replaces css file within doc context, and execute the callback.
		    If a doc is not set, then replaces files in current <code>document</code>.</p>

</div>

</body>
</html>
